<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const obj = {
        a: 1,
        b: 2,
      };

      /* Object.defineProperty(obj, "a", {
        value: 3,
        configurable: false,
        enumerable: false, // 会影响forin以及Object.keys()方法
      }); */

      Object.defineProperties(obj, {
        a: {
          value: 3,
          configurable: false,
          enumerable: false,
        },
      });

      const desc = Object.getOwnPropertyDescriptor(obj, "a");
      console.log(desc);

      for (const key in obj) {
        console.log(key);
      }
      console.log(Object.keys(obj));
    </script>
  </body>
</html>
